
package br.siseventos.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import org.joda.time.DateTime;


public class HashingHelper {
    public static String gerarHash(String username) throws NoSuchAlgorithmException, UnsupportedEncodingException{
        // Percorrer os bytes da String password
        
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        md.update(username.getBytes("UTF-8"));
        
        byte[] result = md.digest();
        
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < result.length; i++) {
          sb.append(Integer.toString((result[i] & 0xff) + 0x100, 16).substring(1));
        }
        
        return sb.toString();
    }
    
}
